<?php
/*  
  Copyright (c) 2010-02 SongCMS 
  SongCMS All Rights Reserved. 
  Support:www.SongCMS.com
  QQ:544255858   19951025
  Author:Song  Version:3.17
  Date:2010-08-12 09:28:32
*/

include_once('Admin.php');
is_numeric($_GET['type']) ? $type = $_GET['type'] : $type = 0;
@!is_numeric($_GET['page']) ? $page = 1 : $page = (int)($_GET['page']);

$Date = date("Y-m-d H:i:s",time()-3600*24*$LogSaveDate); //限止天数的日期
if($_GET['Action']=='DelAll'){
	if ($db->ExecuteSQL("DELETE FROM `" . $dbprefix . "adminlog` WHERE `LogTime` BETWEEN '' AND '" . $Date . "';")){
		AdminLog(3,1,'执行"清空系统日志"操作，结果：操作成功！');
		MsgBox (1,'清空系统日志成功！注意：最近' . $LogSaveDate . '天内的日志会被系统保留。',"AdminLog.php?page=$page&type=$type");
	} else {
		AdminLog(3,1,'执行"清空系统日志"操作，结果：操作失败！');
		MsgBox (1,'清空系统日志失败！',"AdminLog.php?page=$page&type=$type");		
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="./images/adminstyle.css" rel="stylesheet" type="text/css" />
<link rel="Shortcut Icon" href="../favicon.ico" />
<link rel="Bookmark" href="../favicon.ico" />
<script src="../js/csshovernotie6.js" type="text/javascript"></script>
<script type="text/javascript">
<!-- 
function MM_jumpMenu(targ,selObj,restore){ //v3.0 跳转
  open(selObj.value,targ)
  if (restore) selObj.selectedIndex=0;
}
//--> 
</script>
</head>
<body>
<br />
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr class="Notodd"><td>
			<table border="0" cellspacing="2" cellpadding="0">
				<tr>
					<td>&nbsp;请选择日志类型：&nbsp;</td>
					<td>
					<select onChange="MM_jumpMenu('_self',this,0)">
					<option value="AdminLog.php"<?php if($type==0) echo ' selected="selected"';?>>==全部操作日志==</option>
					<option value="AdminLog.php?type=1"<?php if($type==1) echo ' selected="selected"';?>>修改数据操作</option>
					<option value="AdminLog.php?type=2"<?php if($type==2) echo ' selected="selected"';?>>添加数据操作</option>
					<option value="AdminLog.php?type=3"<?php if($type==3) echo ' selected="selected"';?>>删除数据操作</option>
					<option value="AdminLog.php?type=4"<?php if($type==4) echo ' selected="selected"';?>>后台登录日志</option>
					<option value="AdminLog.php?type=5"<?php if($type==5) echo ' selected="selected"';?>>文件上传日志</option>
					<option value="AdminLog.php?type=6"<?php if($type==6) echo ' selected="selected"';?>>数据备份及还原操作</option>
					<option value="AdminLog.php?type=7"<?php if($type==7) echo ' selected="selected"';?>>生成HTML静态文件</option>
					</select>					
					</td>
				</tr>
			</table></td>
		<td align="right">
		<table border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td><a onClick="return confirm('确定清空全部系统日志吗？');" href="?Action=DelAll&page=<?php echo $page?>&type=<?php echo $type?>">清空系统日志</a></td>
			</tr>
		</table>		
		</td>
	</tr>
</table>
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
    <td colspan="5" align="center" class="Main_Title">系统操作日志</td>
  </tr>
  <tr class="odd">
  	<td height="20" align="center" class="b">动作(操作页面)</td>
  	<td align="center" class="b">操作时间</td>
  	<td align="center" class="b">操作者</td>
  	<td align="center" class="b">操作者IP</td>
  	<td align="center" class="b">事件内容</td>
<?php
$PageCount = $AdminLogPage;
$SQL = "SELECT `ID`,`LogType`,`LogLang`,`LogUser`,`LogIP`,`LogTime`,`LogDetails`,`LogPage` FROM `" . $dbprefix . "adminlog` ";
if($type != 0) {$SQL .= "WHERE `LogType` = '" . $type . "' ";}
$RsCount = count($db->SelectSQL($SQL)); //总记录数
$SQL .= "ORDER BY `ID` DESC ";
$SQL .= "LIMIT " . ($page-1)*$PageCount . " , " . $PageCount . " ";
$Rs = $db->SelectSQL($SQL);
if (count($Rs)==0){echo '<tr class="odd"><td height="50" colspan="5" align="center">没有相关日志！</td></tr>';}
for ($i=0;$i<count($Rs);$i++){
	Html($Rs[$i]);
	switch ($Rs[$i][1]){ 
		case 1 : $LogAction = '<font color="#339900">修改数据</font>'; break;
		case 2 : $LogAction = '<font color="#660066">添加数据</font>'; break;
		case 3 : $LogAction = '<font color="#FF0000">删除数据</font>'; break;
		case 4 : $LogAction = '<font color="#0000FF">后台登录</font>'; break;
		case 5 : $LogAction = '<font color="#FF9900">文件上传</font>'; break;
		case 6 : $LogAction = '<font color="#9900FF">数据库备份及还原操作</font>'; break;
		case 7 : $LogAction = '<font color="#660066">生成HTML静态文件</font>'; break;
		default : $LogAction = '<font color="#99999">未知动作</font>'; break;
	}
	$Rs[$i][3] != '' ? $LogUser = $Rs[$i][3] : $LogUser = '<font color="#999999">未登录用户</font>';
	$WebLangKind > 1 ? $LangText = $WebLangName[($Rs[$i][2]-1)] : $LangText = '查看'; //多种语言时显示操作站点语言
	echo '	<tr class="odd">
	<td height="20" align="center">' . $LogAction . '(<a target="_blank" href="' . $Rs[$i][7] . '">' . $LangText . '</a>)' . '</td>
	<td align="center">' . $Rs[$i][5] . '</td>
	<td align="center">' . $LogUser . '</td>
	<td align="center"><a target="_blank" href="../inc/gettopost.php?Action=IP&IP=' . $Rs[$i][4] . '">' . $Rs[$i][4] . '</a></td>
	<td align="left">' . $Rs[$i][6] . '</td>
	</tr>' . "\n";
}
echo '<tr class="odd">
<td height="30" colspan="5" align="center">' . "\n";
echo pages('type=' . $type);
echo '</td></tr>';
?>
</tr></table>
  
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="6">
	<tr class="Notodd">
		<td style="color:#333333; line-height:20px;">
注：1、为确保系统安全，最近<?php echo $LogSaveDate?>天内的日志会被系统保留，无法删除！<br />
　　2、在系统高级参数设定中修改($LogSaveDate = 10)可更改受保护的日志天数；<br />
　　3、将系统高级参数设定中的"$ConfigAdminLog"参数值设置为"0"可关闭网站日志功能；
</td>
	</tr>
</table>  
</body>
</html>